package com.moresir.validatetools.common.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseDTO<T> {

    public ResponseDTO(Integer code, String message) {
        this.code = code;
        this.msg = message;
    }

    public static <T> ResponseDTO<T> build(ResponseEnum responseEnum) {
        return new ResponseDTO<>(responseEnum.getCode(), responseEnum.getZhMsg());
    }

    public static <T> ResponseDTO<T> build(ResponseEnum responseEnum, T t) {
        return new ResponseDTO<>(responseEnum.getCode(), responseEnum.getZhMsg(), t);
    }

    public static <T> ResponseDTO<T> build(Integer code, String message) {
        return new ResponseDTO<>(code, message);
    }

    public static <T> ResponseDTO<T> build(Integer code, String message, T t) {
        return new ResponseDTO<>(code, message, t);
    }

    private Integer code;
    private String msg;
    private T data;
}
